//
//  SJLabelCell.m
//  WSL
//
//  Created by CJ on 2018/3/26.
//  Copyright © 2018年 sanjuetech. All rights reserved.
//

#import "SJLabelCell.h"
#import "SJLabelItem.h"

@interface SJLabelCell ()

@property (strong, nonatomic) UILabel *labelLabel;

@end

@implementation SJLabelCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self.contentView addSubview:self.labelLabel];
    self.labelLabel.sd_layout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 0, 0));
}

- (void)setItem:(SJLabelItem *)item {
    
    _item = item;
    self.labelLabel.text = item.name;
    
    if (item.isSelected) {
        
        _labelLabel.layer.borderColor = [UIColor whiteColor].CGColor;//边框颜色
        
    } else {
        
        _labelLabel.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        
    }
    
}

- (UILabel *)labelLabel {
    
    if (!_labelLabel) {
        
        _labelLabel = [UILabel new];
        _labelLabel.numberOfLines = 1;
        _labelLabel.textAlignment = NSTextAlignmentCenter;
        _labelLabel.textColor = [UIColor whiteColor];
        _labelLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(16)];
        _labelLabel.sd_cornerRadius = @(SJCornerRadius);
        _labelLabel.backgroundColor = SJColorHexString(@"#ffffff19");
        _labelLabel.layer.borderWidth = SJLayoutFrame(1);//边框宽度
        _labelLabel.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        
    }
    return _labelLabel;
}

@end
